package cn.iocoder.yudao.module.promotion.dal.mysql.shortlinkdetail;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.promotion.controller.admin.shortlinkdetail.vo.ShortLinkDetailExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.shortlinkdetail.vo.ShortLinkDetailPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.shortlinkdetail.ShortLinkDetailDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 短链接列 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ShortLinkDetailMapper extends BaseMapperX<ShortLinkDetailDO> {

    default PageResult<ShortLinkDetailDO> selectPage(ShortLinkDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShortLinkDetailDO>()
                .likeIfPresent(ShortLinkDetailDO::getName, reqVO.getName())
                .eqIfPresent(ShortLinkDetailDO::getShortLinkId, reqVO.getShortLinkId())
                .eqIfPresent(ShortLinkDetailDO::getBatchNumber, reqVO.getBatchNumber())
                .eqIfPresent(ShortLinkDetailDO::getShortUrl, reqVO.getShortUrl())
                .eqIfPresent(ShortLinkDetailDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(ShortLinkDetailDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ShortLinkDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShortLinkDetailDO::getId));
    }

    IPage<ShortLinkDetailDO> selectListPage(Page<?> page,@Param("reqVO") ShortLinkDetailPageReqVO reqVO);

    default List<ShortLinkDetailDO> selectList(ShortLinkDetailExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShortLinkDetailDO>()
                .likeIfPresent(ShortLinkDetailDO::getName, reqVO.getName())
                .eqIfPresent(ShortLinkDetailDO::getShortLinkId, reqVO.getShortLinkId())
                .eqIfPresent(ShortLinkDetailDO::getBatchNumber, reqVO.getBatchNumber())
                .eqIfPresent(ShortLinkDetailDO::getShortUrl, reqVO.getShortUrl())
                .eqIfPresent(ShortLinkDetailDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(ShortLinkDetailDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ShortLinkDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShortLinkDetailDO::getId));
    }
    default void deleteByShortLinkId(Long shortLinkId) {
        delete(new LambdaQueryWrapperX<ShortLinkDetailDO>().eq(ShortLinkDetailDO::getShortLinkId, shortLinkId));
    }
}
